﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Threading;
using System.Windows.Forms;

namespace B08_摇奖机
{
    public partial class Form1 : Form
    {
        public Form1()
        {
            InitializeComponent();
        }

        Thread thread;

        private void Btn_Start_Click(object sender, EventArgs e)
        {
            if (thread != null && thread.IsAlive)
            {
                thread.Abort();
                
                this.btn_Start.Text = "开始";
            }
            else
            {
                thread = new Thread(Run);
                thread.Start();
                this.btn_Start.Text = "停止";
            }
        }

        private void Run()
        {
            Random r = new Random();
            while (true)
            {
                this.label1.Text = r.Next(0, 10).ToString();
                this.label2.Text = r.Next(0, 10).ToString();
                this.label3.Text = r.Next(0, 10).ToString();
                this.label4.Text = r.Next(0, 10).ToString();
                this.label5.Text = r.Next(0, 10).ToString();
                this.label6.Text = r.Next(0, 10).ToString();
            }
        }

        private void Form1_Load(object sender, EventArgs e)
        {
            Control.CheckForIllegalCrossThreadCalls = false;
        }

    }
}
